import Cookies from 'js-cookie';

const TOKEN_KEY = 'admin-token';
const TOKEN_HEADER_KEY = 'token-header'

export const setToken = (token: string) => {
  Cookies.set(TOKEN_KEY, token);
};

export const getToken = () => {
  return Cookies.get(TOKEN_KEY);
};

export const clearToken = () => {
  Cookies.remove(TOKEN_KEY);
  Cookies.remove(TOKEN_HEADER_KEY);
};

export function getTokenHeader() {
  return Cookies.get(TOKEN_HEADER_KEY)
}

export function setTokenHeader(header: string) {
  return Cookies.set(TOKEN_HEADER_KEY, header)
}

export const isLogin = () => {
  return !!getToken();
};
